<?php

use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    return view('welcome');
});

// 管理员页面路由
Route::get('/admin/login', function () {
    return view('admin.login');
});

Route::get('/admin/dashboard', function () {
    // 检查管理员是否已登录
    $token = request()->cookie('admin_token') ?? request()->header('Authorization');
    
    // 如果没有token，检查localStorage（通过JavaScript检查）
    if (!$token) {
        return view('admin.dashboard');
    }
    
    return view('admin.dashboard');
})->name('admin.dashboard');
